using System;
using System.Windows.Forms;
using System.Drawing;
using TestMap;

namespace DrawTools
{
	/// <summary>
	/// Line tool
	/// </summary>
	class ToolLine : DrawTools.ToolObject
	{
        public ToolLine()
        {
            Cursor = new Cursor("Line.cur");
        }

        public override void OnMouseDown(Form1 drawArea, AxMapXLib.CMapXEvents_MouseDownEvent e)
        {
            Point p = new Point((int)e.x, (int)e.y);
            AddNewObject(drawArea, new DrawLine(p.X, p.Y, p.X + 1, p.Y + 1));
        }

        public override void OnMouseMove(Form1 drawArea, AxMapXLib.CMapXEvents_MouseMoveEvent e)
        {
            drawArea.Cursor = Cursor;

            if ( e.button == 1 )
            {
                Point point = new Point((int)e.x, (int)e.y);
                drawArea.GraphicsList[0].MoveHandleTo(point, 2);
                drawArea.MapControl.Refresh();
            }
        }
    }
}
